package com.br.rh.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.br.rh.vo.EstadoCivil;

public class EstadoCivilDAO extends DataUtils {
	public List<EstadoCivil> getAll(){
		Connection conn = null;
		PreparedStatement stmt = null;
		ResultSet rs = null;
		EstadoCivil estadoCivil = null;
		ArrayList<EstadoCivil> lista = new ArrayList<EstadoCivil>();
		
		try {
			conn = getConnection();
			stmt = conn.prepareStatement("SELECT * FROM estado_civil ");
			rs = stmt.executeQuery();
			while(rs.next()){
				estadoCivil = new EstadoCivil();
				estadoCivil.setCodigo(rs.getInt(1));
				estadoCivil.setEstadoCivil(rs.getString(2));
				lista.add(estadoCivil);				
			}
			conn.close();
			stmt.close();
			rs.close();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		return lista;
	}
}
